/**
	* @author		Yuri Visser 		
	* @Created 		
	* @LastUpdated	
	* @Comments		
	* @Notes 			
	* 
**/

package com.theredspace.as3frameworks.puremvc.view {
	
	import com.theredspace.as3frameworks.puremvc.ApplicationFacade;
	import com.theredspace.as3frameworks.puremvc.model.helpers.ZoopIdHelper;
	import com.theredspace.as3frameworks.puremvc.view.components.Zoop;
	import com.theredspace.as3frameworks.puremvc.view.components.ZoopsLair;
	
	import org.puremvc.as3.interfaces.IMediator;
	import org.puremvc.as3.interfaces.INotification;
	import org.puremvc.as3.patterns.mediator.Mediator;
	
	public class ZoopsLairMediator extends Mediator implements IMediator {
		
		public static const NAME:String = "zoopsPenMediator";
		
		public function ZoopsLairMediator(viewComponent:Object) {
			super(NAME, viewComponent);
			
			//---retrieve frequently consulted proxies
		}

		override public function onRegister():void {
			//Register all event listeners in here	
		}
		
		override public function onRemove():void {
			//null vars and remove event listeners	
		}
		
		override public function listNotificationInterests():Array {
			return	[
				ApplicationFacade.ADD_CREATURE_TO_LAIR,
				ApplicationFacade.ADD_CLONE_ZOOP
			];
		}
				
		override public function handleNotification(note:INotification):void {
			var noteData:Object = note.getBody();
			switch(note.getName()) {
				
				case ApplicationFacade.ADD_CREATURE_TO_LAIR:
					var tmpZoop:Zoop = noteData as Zoop;
					zoopsLair.addCreature(tmpZoop);
					tmpZoop.setZoopTravelBounds(zoopsLair.width, zoopsLair.height);
					facade.registerMediator(new ZoopMediator(tmpZoop, ZoopIdHelper.getUniqueID()));
					break;
				
				case ApplicationFacade.ADD_CLONE_ZOOP:
					var cloneZoop:Zoop = new Zoop(noteData.creatureIconClass, noteData.creatureType);
					zoopsLair.addCreature(cloneZoop);
					cloneZoop.setZoopTravelBounds(zoopsLair.width, zoopsLair.height,  false);
					cloneZoop.addCloneProps(noteData);
					facade.registerMediator(new ZoopMediator(cloneZoop, ZoopIdHelper.getUniqueID()));
					break;
			
				default:break;
			}
		}
		
        protected function get zoopsLair():ZoopsLair {
            return viewComponent as ZoopsLair;
        }		
        
		//-----------------------------------------------------------------
		//---cached proxies
		

	/************************************************************************/   
	}  //END CLASS
 
/****************************************************************************/  
}  //END PACKAGE